#!/bin/bash

if [ ! -n "$1" ]; then
	echo "Usage: $0 version"
	exit 0
fi;

if [ ! -f pcl-"$1".tar.gz ]; then
	wget https://github.com/PointCloudLibrary/pcl/archive/pcl-"$1".tar.gz
fi;

echo "Extracting archive..."
tar xf pcl-"$1".tar.gz
mv pcl-pcl-"$1" pcl-"$1"
pushd pcl-"$1"
echo "Removing non-free items..."
rm -rf cuda
rm -rf gpu/utils/include/pcl/gpu/utils/device/cutil_math.h
popd
echo "Compressing free archive..."
tar cJf pcl-"$1".tar.xz pcl-"$1"
echo "Cleaning up..."
rm -rf pcl-"$1"
echo "Done"

